const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
  entry: {
    index:'./src/js/main.js',
    // random:'./src/random.js'
  },
  output: {
    filename: '[name].bundle.js',
    path: path.resolve(__dirname, 'dist'),
    clean: true,
  },
  mode:'development',
  devtool: 'inline-source-map',
  devServer: {
    static: './dist',
    port:3000,
    proxy: {
        '/api': {
          target: 'http://localhost:3001',
          pathRewrite: { '^/api': '' },
        },
    }
  },
  plugins: [
    new HtmlWebpackPlugin({
      title: '管理输出',
      template:'./src/index.html'
    }),
  ],
  module: {
    rules: [
      {
        test: /\.css$/i,
        use: ['style-loader', 'css-loader'],
      },
      {
        test: /\.(png|svg|jpg|jpeg|gif)$/i,
        type: 'asset/resource',
      },
    ],
  },
  optimization: {
    runtimeChunk: 'single',
  },
};